package com.hyjx.framework.component.interfaceservice;

import com.hyjx.framework.common.util.SpringBeanUtil;
import com.hyjx.framework.component.interfaceservice.dataservice.DataServiceModel;
import com.hyjx.framework.component.interfaceservice.datauser.DataUserModel;

import java.util.HashMap;
import java.util.List;
import java.util.Map;


/**
 * 常量
 *
 * @author
 */
@SuppressWarnings("unchecked")
public class InterFaceConstants {
    public static final String INTERFACE_MODULE_NAME = "com.hyjx.framework.component.interfaceservice";
    
    private static InterfaceService service;
    private static Map<String, DataUserModel> usermodelinfo = null;
    private static Map<String, DataServiceModel> dataservicemodel = null;
    
    static {
        service = (InterfaceService) SpringBeanUtil.getBean("interfaceServiceImpl");
        List<DataServiceModel> list = service.queryDataService();
        dataservicemodel = new HashMap<String, DataServiceModel>();
        if (list != null && list.size() > 0) {
            for (DataServiceModel service : list) {
                dataservicemodel.put(service.getSrvid(), service);
            }
        }
        List<DataUserModel> dulist = service.queryUserInfo();
        usermodelinfo = new HashMap<String, DataUserModel>();
        if (dulist != null && dulist.size() > 0) {
            for (DataUserModel datausermodel : dulist) {
                usermodelinfo.put(datausermodel.getUserid(), datausermodel);
            }
        }
    }
    
    private InterFaceConstants() {
    }
    
    public static void setUserConfig() {
        usermodelinfo = null;
    }
    
    public static Map<String, DataUserModel> getUserConfig() {
        return usermodelinfo;
    }
    
    public static void setServiceConfig() {
        dataservicemodel = null;
    }
    
    public static Map<String, DataServiceModel> getServiceConfig() {
        return dataservicemodel;
    }
}